package dao.impl;

import dao.ProductDao;
import domain.Product;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import utils.C3P0Utils;

import java.sql.SQLException;
import java.util.List;

/**
 * @Author admin
 * @Date 2019/2/25 9:21
 */
public class ProductDaoImpl implements ProductDao {
    @Override
    public List<Product> findAll() {
        QueryRunner runnr = new QueryRunner(C3P0Utils.getDateSourse());
        String sql = "SELECT * FROM product";
        try {
            return runnr.query(sql,new BeanListHandler<Product>(Product.class));
        }catch (SQLException e){
            e.printStackTrace();
        }
        return null;
    }
}
